import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig(({ command, mode }) => {
  return {
    main: {
      plugins: [externalizeDepsPlugin()]
    },
    preload: {
      plugins: [externalizeDepsPlugin()]
    },
    renderer: {
      resolve: {
        alias: {
          '@': resolve('src/renderer/src'),
          '@renderer': resolve('src/renderer/src'),
          '@img': resolve('src/renderer/src/assets/images')
        }
      },
      plugins: [vue()],
      server: {
        '/api': {
          target: 'http://59.110.217.95:27017',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, '')
        },
        cors: true
      }
    }
  }
})
